package com.iqik.control;

import com.iqik.service.DemoBService;
import com.iqik.service.DemoCService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/demo")
public class HelloCtrl {

    @Reference(filter = "client_ip_filter")
    private DemoBService demoBService;

    @Reference(filter = "client_ip_filter")
    private DemoCService demoCService;

    @RequestMapping("iqikia")
    public String demo(HttpServletRequest request, HttpServletResponse response) {

        String resultB = demoBService.sayBHello("iqikia");
        System.out.println("get result from service B: " + resultB);
        String resultC = demoCService.sayCHello("iqikia");
        System.out.println("get result from service C: " + resultC);

        return "this is demo of web work";
    }
}
